package com.docmgmt.mvp.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 用户实体（v3.0）
 *
 * @TableName sys_user
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("sys_user")
public class UserEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @TableField("username")
    private String username;

    @TableField("password")
    private String passwordHash;

    @TableField("email")
    private String email;

    @TableField("real_name")
    private String fullName;

    @TableField("phone")
    private String phone;

    @TableField("avatar")
    private String avatarUrl;

    @TableField("dept_id")
    private Long departmentId;

    /** v3.0新增：用户状态（active/inactive/locked） */
    @TableField("status")
    private String status;

    @TableField("storage_quota")
    private Long storageQuota;

    @TableField("used_storage")
    private Long storageUsed;

    @TableField("last_login_time")
    private LocalDateTime lastLoginTime;

    @TableField("last_login_ip")
    private String lastLoginIp;

    /** sys_user表使用status字段代替is_deleted */
    @TableField(exist = false)
    private Boolean deleted;

    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    // ==================== 便捷方法（兼容MyBatis-Plus自动映射）====================

    /**
     * 获取密码（别名方法，供MyBatis-Plus自动映射使用）
     */
    public String getPassword() {
        return this.passwordHash;
    }

    /**
     * 设置密码（别名方法，供MyBatis-Plus自动映射使用）
     */
    public void setPassword(String password) {
        this.passwordHash = password;
    }
    
    // ==================== Setter 方法（为编译添加）====================
    
    public void setUsername(String username) {
        this.username = username;
    }
    
    public void setPasswordHash(String passwordHash) {
        this.passwordHash = passwordHash;
    }
    
    public void setEmail(String email) {
        this.email = email;
    }
    
    public void setFullName(String fullName) {
        this.fullName = fullName;
    }
    
    public void setPhone(String phone) {
        this.phone = phone;
    }
    
    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = avatarUrl;
    }
    
    public void setDepartmentId(Long departmentId) {
        this.departmentId = departmentId;
    }
    
    public void setStatus(String status) {
        this.status = status;
    }
    
    public void setStorageQuota(Long storageQuota) {
        this.storageQuota = storageQuota;
    }
    
    public void setStorageUsed(Long storageUsed) {
        this.storageUsed = storageUsed;
    }
    
    public void setLastLoginTime(LocalDateTime lastLoginTime) {
        this.lastLoginTime = lastLoginTime;
    }
    
    public void setLastLoginIp(String lastLoginIp) {
        this.lastLoginIp = lastLoginIp;
    }
    
    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }
    
    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }
    
    // ==================== Getter 方法（为编译添加）====================
    
    public Long getId() {
        return this.id;
    }
    
    public String getUsername() {
        return this.username;
    }
    
    public String getEmail() {
        return this.email;
    }
    
    public String getFullName() {
        return this.fullName;
    }
    
    public String getPhone() {
        return this.phone;
    }
    
    public String getAvatarUrl() {
        return this.avatarUrl;
    }
    
    public Long getDepartmentId() {
        return this.departmentId;
    }
    
    public String getStatus() {
        return this.status;
    }
    
    public Long getStorageQuota() {
        return this.storageQuota;
    }
    
    public Long getStorageUsed() {
        return this.storageUsed;
    }
    
    public LocalDateTime getLastLoginTime() {
        return this.lastLoginTime;
    }
    
    public String getLastLoginIp() {
        return this.lastLoginIp;
    }
    
    public LocalDateTime getCreatedAt() {
        return this.createdAt;
    }
    
    public LocalDateTime getUpdatedAt() {
        return this.updatedAt;
    }
}